<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Oracle AWR 报告智能分析系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/heroicons/2.0.18/24/outline/heroicons.min.css" rel="stylesheet">
    <style>
        body {
            font-family: 'Inter', 'Helvetica Neue', 'Arial', sans-serif;
        }
        .sidebar-icon {
            width: 24px;
            height: 24px;
        }
        .card {
            background-color: white;
            border-radius: 0.75rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
            transition: all 0.3s ease-in-out;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.1);
        }
        .analysis-card {
            border-left-width: 4px;
            margin-bottom: 1.5rem;
        }
        .phenomenon-section, .suggestion-section {
            padding-left: 1rem;
            border-left: 2px solid #e5e7eb;
            margin-left: 0.5rem;
        }
        .loader {
            border: 5px solid #f3f3f3;
            border-top: 5px solid #3498db;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="flex h-screen">
        <!-- Sidebar -->
        <aside class="w-20 bg-gray-800 text-white flex flex-col items-center py-4">
            <div class="text-2xl font-bold mb-8">DB</div>
            <nav class="flex flex-col space-y-6">
                <a href="#" class="p-2 rounded-lg bg-gray-700" title="首页"><svg class="sidebar-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg></a>
                <a href="#" class="p-2 rounded-lg hover:bg-gray-700" title="分析"><svg class="sidebar-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg></a>
                <a href="#" class="p-2 rounded-lg hover:bg-gray-700" title="报告"><svg class="sidebar-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg></a>
                <a href="#" class="p-2 rounded-lg hover:bg-gray-700" title="设置"><svg class="sidebar-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg></a>
            </nav>
        </aside>

        <!-- Main Content -->
        <main class="flex-1 p-6 overflow-y-auto">
            <header class="flex justify-between items-center mb-6">
                <div>
                    <h1 class="text-2xl font-bold text-gray-800">AWR性能分析报告</h1>
                    <p class="text-gray-500" id="report-subtitle">上传您的AWR HTML报告以开始分析</p>
                </div>
                <div class="flex items-center space-x-4">
                    <label for="file-upload" class="cursor-pointer bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg inline-flex items-center">
                        <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path></svg>
                        上传AWR报告
                    </label>
                    <input id="file-upload" type="file" class="hidden" accept=".html,.htm">
                </div>
            </header>

            <div id="welcome-screen">
                <div class="card text-center py-20">
                    <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 48 48" aria-hidden="true">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 10l-5.447 2.724a1 1 0 00-.553.894V34.382a1 1 0 00.553.894L14 38M14 10v28M14 10l20-10 5.447 2.724a1 1 0 01.553.894V34.382a1 1 0 01-.553.894L34 38M34 10v28M34 10L14 38"></path>
                    </svg>
                    <h3 class="mt-2 text-lg font-medium text-gray-900">请上传您的AWR报告</h3>
                    <p class="mt-1 text-sm text-gray-500">
                        点击右上角的 "上传AWR报告" 按钮，选择一个.html格式的AWR报告文件。
                    </p>
                </div>
            </div>
            
            <div id="loading-screen" class="hidden flex flex-col items-center justify-center card py-20">
                 <div class="loader"></div>
                 <p class="mt-4 text-gray-600">正在解析和分析报告，请稍候...</p>
            </div>
            
            <div id="error-screen" class="hidden card bg-red-50 border-red-500 border-l-4 p-4">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" />
                        </svg>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-red-800" id="error-message">文件解析失败。请确保您上传的是一个有效、完整的Oracle AWR报告HTML文件。</p>
                    </div>
                </div>
            </div>

            <div id="analysis-result" class="hidden">
                <!-- Summary Section -->
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">
                    <div class="card flex items-center p-4">
                        <div class="p-3 rounded-full bg-blue-100 text-blue-500 mr-4">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        </div>
                        <div>
                            <p class="text-sm text-gray-500">DB Time (分钟)</p>
                            <p class="text-2xl font-bold" id="summary-db-time">--</p>
                        </div>
                    </div>
                    <div class="card flex items-center p-4">
                        <div class="p-3 rounded-full bg-green-100 text-green-500 mr-4">
                           <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h5M5.5 9.5A7.5 7.5 0 109.5 5.5"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 14h5v-5"></path></svg>
                        </div>
                        <div>
                            <p class="text-sm text-gray-500">快照范围</p>
                            <p class="text-2xl font-bold" id="summary-snaps">--</p>
                        </div>
                    </div>
                    <div class="card flex items-center p-4">
                        <div class="p-3 rounded-full bg-yellow-100 text-yellow-500 mr-4">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 8v8m-8-8v8m-7 0h18"></path></svg>
                        </div>
                        <div>
                            <p class="text-sm text-gray-500">持续时间 (分钟)</p>
                            <p class="text-2xl font-bold" id="summary-elapsed">--</p>
                        </div>
                    </div>
                    <div class="card flex items-center p-4">
                        <div class="p-3 rounded-full bg-purple-100 text-purple-500 mr-4">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
                        </div>
                        <div>
                            <p class="text-sm text-gray-500">平均活动会话</p>
                            <p class="text-2xl font-bold" id="summary-aas">--</p>
                        </div>
                    </div>
                </div>

                <!-- Performance Score and Top Waits -->
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
                    <div class="card lg:col-span-1 flex flex-col items-center justify-center">
                        <h3 class="text-lg font-semibold text-gray-700 mb-4">整体性能评分</h3>
                        <div class="relative w-48 h-48">
                            <canvas id="performance-score-chart"></canvas>
                            <div id="score-text" class="absolute inset-0 flex items-center justify-center text-4xl font-bold text-gray-800">--</div>
                        </div>
                    </div>
                    <div class="card lg:col-span-2">
                         <h3 class="text-lg font-semibold text-gray-700 mb-4">Top 5 前台等待事件</h3>
                         <div id="top-waits-container">
                            <p class="text-gray-500">无明显等待事件。</p>
                         </div>
                    </div>
                </div>
                
                <!-- Analysis Cards Container -->
                <div id="analysis-cards-container">
                    <!-- Cards will be dynamically inserted here -->
                </div>
            </div>
        </main>
    </div>

    <script>
        // ... JavaScript code will be here ...
    </script>
</body>
</html>
